package com.yfyszk.kingbird.global;


import com.yfyszk.kingbird.exception.GlobalServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * Controller统一异常处理
 *
 * @author : wgc
 * @date : 2018/05/08
 */

@ControllerAdvice
public class AllControllerAdvice {
    private static Logger logger = LoggerFactory.getLogger(AllControllerAdvice.class);


    /**
     * 拦截业务异常
     */

    @ExceptionHandler(GlobalServiceException.class)
    @ResponseBody
    public Object notFount(GlobalServiceException e) {
        logger.error("业务异常:{}", e.getMsg());
        return GLApiResult.error(e.getMsg());
    }


}

